<!--  -->
<template>
    <div>
        商品名称: <input type="text" v-model="name">
        商品价格: <input type="text" v-model="price">
        <button @click="add">增加商品</button>
    </div>
</template>
  
<script>
import { mapMutations } from 'vuex';


export default {
    name: 'Com',
    data() {
        return {
            name: '',
            price: ''
        };
    },

    components: {},

    computed: {

    },

    mounted() { },

    methods: {
        ...mapMutations(['add']),
        add() {
            var obj = { name: this.name, price: this.price }
            this.$store.commit('add', obj)
            this.name = ''
            this.price = ''
        }
    },
    watch: {},
    mixins: []
}

</script>
<style  scoped>

</style>